/*
 * Decompiled with CFR 0.150.
 * 
 * Could not load the following classes:
 *  cn.hutool.core.date.DateUtil
 *  cn.hutool.core.util.ObjectUtil
 *  de.felixroske.jfxsupport.FXMLController
 *  javafx.event.ActionEvent
 *  javafx.fxml.FXML
 *  javafx.fxml.Initializable
 *  javafx.scene.control.Alert
 *  javafx.scene.control.Alert$AlertType
 *  javafx.scene.control.ComboBox
 *  javafx.scene.layout.AnchorPane
 *  org.springframework.beans.factory.annotation.Autowired
 */
package com.gys.controller.baseSetting.saleSchedule;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.gys.common.business.SaleScheduleSettingUtil;
import com.gys.common.data.HttpJson;
import com.gys.common.data.KeyValue;
import com.gys.common.plugIn.dateTimePicker.DateTimePicker;
import com.gys.common.util.CacheUtil;
import com.gys.common.util.CommonUtil;
import com.gys.controller.BaseController;
import com.gys.controller.baseSetting.saleSchedule.SaleScheduleSettingController;
import com.gys.controller.dataManger.ControllerManger;
import com.gys.data.example.GetLoginStoreOutData;
import com.gys.data.example.GetUserOutData;
import com.gys.data.saleScheduleSetting.GetSaleScheduleInData;
import de.felixroske.jfxsupport.FXMLController;
import java.net.URL;
import java.util.Date;
import java.util.HashSet;
import java.util.ResourceBundle;
import java.util.Set;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
import javafx.scene.control.ComboBox;
import javafx.scene.layout.AnchorPane;
import org.springframework.beans.factory.annotation.Autowired;

@FXMLController
public class AddSaleScheduleController
extends BaseController
implements Initializable {
    @FXML
    private ComboBox<KeyValue> addGsegEmp2;
    @FXML
    private ComboBox<KeyValue> addGsegEmp1;
    @FXML
    private ComboBox<KeyValue> addGsegEmp4;
    @FXML
    private ComboBox<KeyValue> addGsegEmp3;
    @FXML
    private DateTimePicker addGsegEndTime;
    @FXML
    private ComboBox<KeyValue> addGsegEmp5;
    @FXML
    private ComboBox<KeyValue> addGsegName;
    @FXML
    private AnchorPane pane;
    @FXML
    private DateTimePicker addGsegBeginTime;
    @Autowired
    private SaleScheduleSettingController saleScheduleSettingController;

    public void initialize(URL location, ResourceBundle resources) {
        ControllerManger.controllerMap.put(this.getClass().getSimpleName(), this);
        this.addGsegEndTime.setPrefHeight(60.0);
        this.saleScheduleSettingController.comboxInit(this.addGsegName);
        this.saleScheduleSettingController.comboxInit(this.addGsegEmp1);
        this.saleScheduleSettingController.comboxInit(this.addGsegEmp2);
        this.saleScheduleSettingController.comboxInit(this.addGsegEmp3);
        this.saleScheduleSettingController.comboxInit(this.addGsegEmp4);
        this.saleScheduleSettingController.comboxInit(this.addGsegEmp5);
        this.addGsegName.setItems(this.saleScheduleSettingController.getGsegNameOptions());
        this.addGsegEmp1.setItems(this.saleScheduleSettingController.getEmpOptions());
        this.addGsegEmp2.setItems(this.saleScheduleSettingController.getEmpOptions());
        this.addGsegEmp3.setItems(this.saleScheduleSettingController.getEmpOptions());
        this.addGsegEmp4.setItems(this.saleScheduleSettingController.getEmpOptions());
        this.addGsegEmp5.setItems(this.saleScheduleSettingController.getEmpOptions());
        this.init();
    }

    @Override
    public void init() {
        if (ObjectUtil.isEmpty(this.pane)) {
            return;
        }
        this.addGsegName.setValue(null);
        this.addGsegEmp1.setValue(null);
        this.addGsegEmp2.setValue(null);
        this.addGsegEmp3.setValue(null);
        this.addGsegEmp4.setValue(null);
        this.addGsegEmp5.setValue(null);
        this.addGsegBeginTime.setTime("");
        this.addGsegEndTime.setTime("");
    }

    @FXML
    private void save(ActionEvent event) {
        if (!this.addSaveCheck()) {
            return;
        }
        GetSaleScheduleInData inData = new GetSaleScheduleInData();
        inData.setClientId(((GetUserOutData)CacheUtil.get("logInUser")).getClient());
        inData.setGsegBeginTime(this.addGsegBeginTime.getTime());
        inData.setGsegEndTime(this.addGsegEndTime.getTime());
        inData.setGsegBrId(((GetLoginStoreOutData)CacheUtil.get("store")).getStoCode());
        inData.setGsegBrName(((GetLoginStoreOutData)CacheUtil.get("store")).getStoName());
        inData.setGsegName(((KeyValue)this.addGsegName.getValue()).getValue());
        HashSet empSet = new HashSet();
        if (ObjectUtil.isNotEmpty(this.addGsegEmp1.getValue())) {
            inData.setGsegEmpId1(((KeyValue)this.addGsegEmp1.getValue()).getValue());
        }
        if (ObjectUtil.isNotEmpty(this.addGsegEmp2.getValue())) {
            inData.setGsegEmpId2(((KeyValue)this.addGsegEmp2.getValue()).getValue());
        }
        if (ObjectUtil.isNotEmpty(this.addGsegEmp3.getValue())) {
            inData.setGsegEmpId3(((KeyValue)this.addGsegEmp3.getValue()).getValue());
        }
        if (ObjectUtil.isNotEmpty(this.addGsegEmp4.getValue())) {
            inData.setGsegEmpId4(((KeyValue)this.addGsegEmp4.getValue()).getValue());
        }
        if (ObjectUtil.isNotEmpty(this.addGsegEmp5.getValue())) {
            inData.setGsegEmpId5(((KeyValue)this.addGsegEmp5.getValue()).getValue());
        }
        inData.setGsegUpdateDate(DateUtil.format((Date)DateUtil.date(), (String)"yyyyMMdd"));
        GetUserOutData user = this.getLoginUser();
        inData.setGsegUpdateEmp(user.getAccount());
        HttpJson httpJson = SaleScheduleSettingUtil.addSave(CommonUtil.convertToMap(inData));
        boolean result = CommonUtil.handleHttpResOnlyAlert(httpJson, "\u4fdd\u5b58\u6210\u529f");
        if (result) {
            this.addGsegName.setValue(null);
            this.addGsegBeginTime.setTime("");
            this.addGsegEndTime.setTime("");
            this.addGsegEmp1.setValue(new KeyValue());
            this.addGsegEmp2.setValue(new KeyValue());
            this.addGsegEmp3.setValue(new KeyValue());
            this.addGsegEmp4.setValue(new KeyValue());
            this.addGsegEmp5.setValue(new KeyValue());
        }
        this.saleScheduleSettingController.init();
        this.closeAction();
    }

    public boolean addSaveCheck() {
        String message = "";
        if (ObjectUtil.isEmpty(this.addGsegBeginTime.getTime())) {
            message = "\u5f00\u59cb\u65f6\u95f4\u4e0d\u53ef\u4e3a\u7a7a";
        } else if (ObjectUtil.isEmpty(this.addGsegEndTime.getTime())) {
            message = "\u7ed3\u675f\u65f6\u95f4\u4e0d\u53ef\u4e3a\u7a7a";
        } else if (ObjectUtil.isEmpty(this.addGsegName.getValue())) {
            message = "\u73ed\u6b21\u63cf\u8ff0\u4e0d\u53ef\u4e3a\u7a7a";
        }
        HashSet empSet = new HashSet();
        if (ObjectUtil.isNotEmpty(this.addGsegEmp1.getValue()) && !this.checkSameEmp(empSet, ((KeyValue)this.addGsegEmp1.getValue()).getValue())) {
            return false;
        }
        if (ObjectUtil.isNotEmpty(this.addGsegEmp2.getValue()) && !this.checkSameEmp(empSet, ((KeyValue)this.addGsegEmp2.getValue()).getValue())) {
            return false;
        }
        if (ObjectUtil.isNotEmpty(this.addGsegEmp3.getValue()) && !this.checkSameEmp(empSet, ((KeyValue)this.addGsegEmp3.getValue()).getValue())) {
            return false;
        }
        if (ObjectUtil.isNotEmpty(this.addGsegEmp4.getValue()) && !this.checkSameEmp(empSet, ((KeyValue)this.addGsegEmp4.getValue()).getValue())) {
            return false;
        }
        if (ObjectUtil.isNotEmpty(this.addGsegEmp5.getValue()) && !this.checkSameEmp(empSet, ((KeyValue)this.addGsegEmp5.getValue()).getValue())) {
            return false;
        }
        if (ObjectUtil.isNotEmpty(message)) {
            Alert alert = this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", message);
            alert.showAndWait();
            return false;
        }
        return true;
    }

    private boolean checkSameEmp(Set empSet, String value) {
        if (ObjectUtil.isNotEmpty(value) && !empSet.add(value)) {
            Alert alert = this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", "\u540c\u4e00\u4e2a\u73ed\u6b21\u7684\u5458\u5de5\u4e0d\u80fd\u91cd\u590d");
            alert.showAndWait();
            return false;
        }
        return true;
    }

    @FXML
    private void closeAction() {
        this.pane.getScene().getWindow().hide();
    }

    public ComboBox<KeyValue> getAddGsegEmp2() {
        return this.addGsegEmp2;
    }

    public ComboBox<KeyValue> getAddGsegEmp1() {
        return this.addGsegEmp1;
    }

    public ComboBox<KeyValue> getAddGsegEmp4() {
        return this.addGsegEmp4;
    }

    public ComboBox<KeyValue> getAddGsegEmp3() {
        return this.addGsegEmp3;
    }

    public DateTimePicker getAddGsegEndTime() {
        return this.addGsegEndTime;
    }

    public ComboBox<KeyValue> getAddGsegEmp5() {
        return this.addGsegEmp5;
    }

    public ComboBox<KeyValue> getAddGsegName() {
        return this.addGsegName;
    }

    public AnchorPane getPane() {
        return this.pane;
    }

    public DateTimePicker getAddGsegBeginTime() {
        return this.addGsegBeginTime;
    }

    public SaleScheduleSettingController getSaleScheduleSettingController() {
        return this.saleScheduleSettingController;
    }

    public void setAddGsegEmp2(ComboBox<KeyValue> addGsegEmp2) {
        this.addGsegEmp2 = addGsegEmp2;
    }

    public void setAddGsegEmp1(ComboBox<KeyValue> addGsegEmp1) {
        this.addGsegEmp1 = addGsegEmp1;
    }

    public void setAddGsegEmp4(ComboBox<KeyValue> addGsegEmp4) {
        this.addGsegEmp4 = addGsegEmp4;
    }

    public void setAddGsegEmp3(ComboBox<KeyValue> addGsegEmp3) {
        this.addGsegEmp3 = addGsegEmp3;
    }

    public void setAddGsegEndTime(DateTimePicker addGsegEndTime) {
        this.addGsegEndTime = addGsegEndTime;
    }

    public void setAddGsegEmp5(ComboBox<KeyValue> addGsegEmp5) {
        this.addGsegEmp5 = addGsegEmp5;
    }

    public void setAddGsegName(ComboBox<KeyValue> addGsegName) {
        this.addGsegName = addGsegName;
    }

    public void setPane(AnchorPane pane) {
        this.pane = pane;
    }

    public void setAddGsegBeginTime(DateTimePicker addGsegBeginTime) {
        this.addGsegBeginTime = addGsegBeginTime;
    }

    public void setSaleScheduleSettingController(SaleScheduleSettingController saleScheduleSettingController) {
        this.saleScheduleSettingController = saleScheduleSettingController;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof AddSaleScheduleController)) {
            return false;
        }
        AddSaleScheduleController other = (AddSaleScheduleController)o;
        if (!other.canEqual(this)) {
            return false;
        }
        ComboBox<KeyValue> this$addGsegEmp2 = this.getAddGsegEmp2();
        ComboBox<KeyValue> other$addGsegEmp2 = other.getAddGsegEmp2();
        if (this$addGsegEmp2 == null ? other$addGsegEmp2 != null : !this$addGsegEmp2.equals(other$addGsegEmp2)) {
            return false;
        }
        ComboBox<KeyValue> this$addGsegEmp1 = this.getAddGsegEmp1();
        ComboBox<KeyValue> other$addGsegEmp1 = other.getAddGsegEmp1();
        if (this$addGsegEmp1 == null ? other$addGsegEmp1 != null : !this$addGsegEmp1.equals(other$addGsegEmp1)) {
            return false;
        }
        ComboBox<KeyValue> this$addGsegEmp4 = this.getAddGsegEmp4();
        ComboBox<KeyValue> other$addGsegEmp4 = other.getAddGsegEmp4();
        if (this$addGsegEmp4 == null ? other$addGsegEmp4 != null : !this$addGsegEmp4.equals(other$addGsegEmp4)) {
            return false;
        }
        ComboBox<KeyValue> this$addGsegEmp3 = this.getAddGsegEmp3();
        ComboBox<KeyValue> other$addGsegEmp3 = other.getAddGsegEmp3();
        if (this$addGsegEmp3 == null ? other$addGsegEmp3 != null : !this$addGsegEmp3.equals(other$addGsegEmp3)) {
            return false;
        }
        DateTimePicker this$addGsegEndTime = this.getAddGsegEndTime();
        DateTimePicker other$addGsegEndTime = other.getAddGsegEndTime();
        if (this$addGsegEndTime == null ? other$addGsegEndTime != null : !((this$addGsegEndTime)).equals(other$addGsegEndTime)) {
            return false;
        }
        ComboBox<KeyValue> this$addGsegEmp5 = this.getAddGsegEmp5();
        ComboBox<KeyValue> other$addGsegEmp5 = other.getAddGsegEmp5();
        if (this$addGsegEmp5 == null ? other$addGsegEmp5 != null : !this$addGsegEmp5.equals(other$addGsegEmp5)) {
            return false;
        }
        ComboBox<KeyValue> this$addGsegName = this.getAddGsegName();
        ComboBox<KeyValue> other$addGsegName = other.getAddGsegName();
        if (this$addGsegName == null ? other$addGsegName != null : !this$addGsegName.equals(other$addGsegName)) {
            return false;
        }
        AnchorPane this$pane = this.getPane();
        AnchorPane other$pane = other.getPane();
        if (this$pane == null ? other$pane != null : !this$pane.equals(other$pane)) {
            return false;
        }
        DateTimePicker this$addGsegBeginTime = this.getAddGsegBeginTime();
        DateTimePicker other$addGsegBeginTime = other.getAddGsegBeginTime();
        if (this$addGsegBeginTime == null ? other$addGsegBeginTime != null : !((this$addGsegBeginTime)).equals(other$addGsegBeginTime)) {
            return false;
        }
        SaleScheduleSettingController this$saleScheduleSettingController = this.getSaleScheduleSettingController();
        SaleScheduleSettingController other$saleScheduleSettingController = other.getSaleScheduleSettingController();
        return !(this$saleScheduleSettingController == null ? other$saleScheduleSettingController != null : !(this$saleScheduleSettingController).equals(other$saleScheduleSettingController));
    }

    protected boolean canEqual(Object other) {
        return other instanceof AddSaleScheduleController;
    }

    public int hashCode() {
        int PRIME = 59;
        int result = 1;
        ComboBox<KeyValue> $addGsegEmp2 = this.getAddGsegEmp2();
        result = result * 59 + ($addGsegEmp2 == null ? 43 : $addGsegEmp2.hashCode());
        ComboBox<KeyValue> $addGsegEmp1 = this.getAddGsegEmp1();
        result = result * 59 + ($addGsegEmp1 == null ? 43 : $addGsegEmp1.hashCode());
        ComboBox<KeyValue> $addGsegEmp4 = this.getAddGsegEmp4();
        result = result * 59 + ($addGsegEmp4 == null ? 43 : $addGsegEmp4.hashCode());
        ComboBox<KeyValue> $addGsegEmp3 = this.getAddGsegEmp3();
        result = result * 59 + ($addGsegEmp3 == null ? 43 : $addGsegEmp3.hashCode());
        DateTimePicker $addGsegEndTime = this.getAddGsegEndTime();
        result = result * 59 + ($addGsegEndTime == null ? 43 : (($addGsegEndTime)).hashCode());
        ComboBox<KeyValue> $addGsegEmp5 = this.getAddGsegEmp5();
        result = result * 59 + ($addGsegEmp5 == null ? 43 : $addGsegEmp5.hashCode());
        ComboBox<KeyValue> $addGsegName = this.getAddGsegName();
        result = result * 59 + ($addGsegName == null ? 43 : $addGsegName.hashCode());
        AnchorPane $pane = this.getPane();
        result = result * 59 + ($pane == null ? 43 : $pane.hashCode());
        DateTimePicker $addGsegBeginTime = this.getAddGsegBeginTime();
        result = result * 59 + ($addGsegBeginTime == null ? 43 : (($addGsegBeginTime)).hashCode());
        SaleScheduleSettingController $saleScheduleSettingController = this.getSaleScheduleSettingController();
        result = result * 59 + ($saleScheduleSettingController == null ? 43 : ($saleScheduleSettingController).hashCode());
        return result;
    }

    public String toString() {
        return "AddSaleScheduleController(addGsegEmp2=" + this.getAddGsegEmp2() + ", addGsegEmp1=" + this.getAddGsegEmp1() + ", addGsegEmp4=" + this.getAddGsegEmp4() + ", addGsegEmp3=" + this.getAddGsegEmp3() + ", addGsegEndTime=" + (this.getAddGsegEndTime()) + ", addGsegEmp5=" + this.getAddGsegEmp5() + ", addGsegName=" + this.getAddGsegName() + ", pane=" + this.getPane() + ", addGsegBeginTime=" + (this.getAddGsegBeginTime()) + ", saleScheduleSettingController=" + this.getSaleScheduleSettingController() + ")";
    }
}

